package cn.initcap.concurrency.concurrency.mq;

import cn.initcap.concurrency.concurrency.mq.kafka.KafKaSender;
import cn.initcap.concurrency.concurrency.mq.rabbitmq.RabbitMqClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author initcap
 * @date Created in 2018/6/20 AM8:58.
 */
@Controller
@RequestMapping("/send")
public class MqController {

    private RabbitMqClient rabbitMQClient;
    private KafKaSender kafKaSender;

    @Autowired
    public MqController(RabbitMqClient rabbitMQClient, KafKaSender kafKaSender) {
        this.rabbitMQClient = rabbitMQClient;
        this.kafKaSender = kafKaSender;
    }

    @RequestMapping("/send")
    @ResponseBody
    public String send(@RequestParam("message") String message) {
        rabbitMQClient.send(message);
        kafKaSender.send(message);
        return "success";
    }

}
